<%--
  Created by IntelliJ IDEA.
  User: CBo
  Date: 2025/10/20
  Time: 10:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<style>
  .card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: none;
    margin-bottom: 1.5rem;
  }
</style>

<jsp:include page="header.jsp"/>
<div class="container mt-4">
  <div class="d-flex justify-content-between align-items-center mb-3">
    <h3><i class="fas fa-tasks"></i> 考试列表</h3>
  </div>

  <!-- 考试场次列表 -->
  <div class="card">
    <div class="card-body">
      <table class="table table-hover table-striped">
        <thead>
        <tr>
          <th>ID</th>
          <th>考试名称</th>
          <th>开始时间</th>
          <th>考试时长(分钟)</th>
          <th>课程</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:set var="examList" value="${requestScope.examList}"/>
        <c:if test="${empty examList}">
          <tr>
            <td colspan="9" class="text-center">暂无考试数据</td>
          </tr>
        </c:if>
        <c:forEach var="exam" items="${examList}">
          <tr>
            <td>${exam.id}</td>
            <td>${exam.examName}</td>
            <td>${exam.startTime}</td>
            <td>${exam.duration}</td>
            <td>${exam.courseName}</td>
            <td>
              <c:choose>
                <c:when test="${exam.state == 0}">
                  <span class="badge bg-secondary">未开始</span>
                </c:when>
                <c:when test="${exam.state == 1}">
                  <span class="badge bg-success">进行中</span>
                </c:when>
                <c:when test="${exam.state == 2}">
                  <span class="badge bg-primary">已结束</span>
                </c:when>
                <c:otherwise>
                  <span class="badge bg-light">未知状态</span>
                </c:otherwise>
              </c:choose>
            </td>
            <td>
              <c:choose>
                <c:when test="${exam.state == 0}">
                  <button class="btn btn-sm btn-success" disabled>开始考试</button>
                </c:when>
                <c:when test="${exam.state == 1}">
                  <button class="btn btn-sm btn-warning">开始考试</button>
                </c:when>
                <c:otherwise>
                  <button class="btn btn-sm btn-secondary" disabled>已结束</button>
                </c:otherwise>
              </c:choose>
            </td>
          </tr>
        </c:forEach>
        </tbody>

      </table>
    </div>
  </div>
</div>

<jsp:include page="footer.jsp"/>


